package com.util.common.sql;

public class MysqlBlockImp extends AbstractCommSQLBlock implements MysqlBlock {
	
	@Override
	public String dateFormate(String dateField, String formate){
		return " date_format("+dateField+",'"+formate+"') ";
	}

	@Override
	public String dateParse(String dateValue, String formate) {
		return " date('"+dateValue+"') ";
	}

	@Override
	public String mergeBetween(String sql, String between, String orderByColumn) {
		orderByColumn = ( orderByColumn != null && !"".equals(orderByColumn.trim()) ) ?
									" ORDER BY " + orderByColumn : "";	
		String sqlStr = " SET @rownum=0; SELECT results.* FROM ("
					+ "SELECT t2.*,@rownum:=@rownum+1 AS  rownumber FROM ("
					+ sql + orderByColumn + ")t2"
					+ ")results WHERE results.rownumber BETWEEN "+ between + orderByColumn;
		return sqlStr;
	}
	
}
